package com.zansc.longd.config.web;

import com.zansc.longd.exception.ServiceException;
import com.zansc.longd.model.base.bean.ResponseBean;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.servlet.http.HttpServletRequest;

@RestControllerAdvice
public class GlobalExceptionHandler {
    
    @ExceptionHandler(value = ServiceException.class)
    @ResponseBody
    public ResponseBean serviceExceptionHandler(HttpServletRequest request, ServiceException e) {
        return ResponseBean.error(e.getErrorCode(), e.getErrorMsg());
    }
    
}
